perm filename MENTOR.ARR[UP,DOC] blob
sn#540903 filedate 1980-10-12 generic text, type C, neo UTF8
COMMENT ā VALID 00028 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00003 00002
C00009 00003 Preface to the Revised Version:
C00013 00004 CONTENTS
C00015 00005 The MENTOR Program Manipulation System
C00018 00006 1. Filing System - 2 -
C00021 00007 2.1. Markers - 3 -
C00024 00008 2.2. Structural Addresses - 4 -
C00027 00009 2.2. Structural Addresses - 5 -
C00030 00010 2.2. Structural Addresses - 6 -
C00033 00011 3.1. Handling of Markers - 7 -
C00036 00012 3.2. Handling Trees - 8 -
C00039 00013 3.2. Handling Trees - 9 -
C00043 00014 4.2. Loop - 10 -
C00046 00015 4.7. Comments - 11 -
C00047 00016 Appendix A -Sample session
C00049 00017 Appendix A - 13 -
C00052 00018 Appendix A - 14 -
C00054 00019 Appendix A - 15 -
C00056 00020 Appendix A - 16 -
C00058 00021 Appendix A - 17 -
C00061 00022 Appendix A - 18 -
C00065 00023 Appendix B -System constants
C00068 00024 Appendix C -The Abstract syntax of Pascal
C00073 00025 Appendix C - 21 -
C00076 00026 Appendix C - 22 -
C00079 00027 Appendix D - Entry points in the PASCAL parser
C00082 00028
C00083 ENDMK
Cā;
MENTOR
PROGRAM MANIPULATION SYSTEM
V. Donzeau - Gouge G. Huet
G. Kahn B. Lang
IRIA-Laboria
30-August 1979
Revised Version
A. Rodriguez
14 September 1979
ABSTRACT: A Rough user's manual is presented for the
Program Manipulation System MENTOR. This manual
effectively describes the MENTOR Manipulation Language,
MENTOL. Some brief examples are given, and a sample
session is included in one of the appendices. No attempt
Is made to describe the Philosophy of the System, its
story or future plans. Appendices are provided that list
all the predefined names that may be needed by the user.
Preface to the Revised Version:
------------------------------
This document was originally written using the typesetter system SCRIBE.
In order to provide users with an online document that describes MENTOR,
the original file was reformatted into a standard ASCII file. In the
process, The section numbering system, the paging and the representation
of the syntax were modified, but the contents of the document itself was
not altered. This revised version is three pages longer than the original
document. A table of contents follows.
Although the aim was to get an online, terminal-readable file, the
general format of the file is still suitable for printing. Where fonts
were used to single out particular items, Upper case and underlining have
been used.
If you don't have access to Mentor, and would be interested on having it
on a DEC-10 or DEC-20 computer, you can contact me to arrange it to
provide you with the MENTOR system in relocatable or executable form. If
you desire to have it implemented in a different machine, or to have
access to the sources, please contact Gilles Kahn.
Armando R. Rodriguez
Computer Science Department
Stanford University
Stanford, CA 94305
(415)497-4971
Arpanet: ARR@SU-AI
Other documents related to MENTOR:
V. Donzeau-Gouge, G. Huet, G. Kahn, B. Lang, J.J. Levy. A
Structure oriented program editor: a first step towards computer
assisted programming. In Proceedings of the International
Computing Symposium 1975, North Holland. Also Rapport de Recherche
n. 114, IRIA-Laboria, April 1975.
To contact the authors, write to
Gilles Kahn
IRIA - Laboria
Domaine de Voluceau
B.P. 105
78150 Le Chesnay
Or, over the Arpanet, contact GKahn.Bat20@MIT-Multics or Huet@SRI-KL
(Notice that the mailer at Multics is NOT case blind).
CONTENTS
Page.
Introduction. 1
1. Filing System. 1
2. Addressing Mechanism. 2
2.1. Markers. 2
2.2. Structural Addresses. 3
2.2.1. Immediate Modifiers. 3
2.2.2. Search Modifiers. 4
3. Primitive Commands. 7
3.1. Handling of Markers. 7
3.1.1. Assignment. 7
3.1.2. Stack Manipulation. 7
3.2. Handling Trees. 7
3.2.1. Printing. 7
3.2.2. Copying. 8
3.2.3. Deleting. 8
3.2.4. Changing Trees. 8
3.2.5. Exchanging Trees. 8
3.2.6. Insertion Within Lists. 9
4. Control Constructs. 9
4.1. Sequencing. 9
4.2. Loop. 10
4.3. Test. 10
4.4. Case Command. 10
4.5. Exit. 10
4.6. Procedure Call 10
4.7. Comments. 11
Appendix A - Sample Session. 12
Appendix B - System Constants. 19
Appendix C - The Abstract Syntax of PASCAL. 20
Appendix D - Entry Points in the PASCAL Parser. 23
The MENTOR Program Manipulation System
--------------------------------------
Rough User's Manual
Introduction
------------
To call MENTOR, just type: MENTOR <CR>
You are then prompted with a silly message that you should ignore. Type
another <CR>
MENTOR types in:
- MENTOR VERSION 3.5 / JUN-79 ON DEC-10 (HAMBURG)
USER NAME:
The system wants to know who you are for two reasons:
1. So that it can retrieve a file (i.e. yourname.INI), where you
describe what you want to do when you first enter the system.
2. So that your name can be known by filing procedures in the
system.
I shall assume that your file (yourname.INI) is a copy of mine
(KAHN.INI). After you have given your name to the system (remember to
terminate all MENTOR input with <CR>), you are in business.
1. MENTOR expects commands from you and signals this fact by
printing a question mark.
2. You can type your requests either in upper or lower case.
MENTOR is case blind on input.
1. Filing System
----------------
MENTOR uses the extension of the files it handles to distinguish their
types, according to the table below:
Extension Type
.PAS Text file in PASCAL
.POL Tree from (a fragment of PASCAL program)
.MOL Command file for MENTOR
.INI Prelude file.
You never have to worry about these extensions. They are automatically
supplied by the system. They are indicated here so that you understand
what is happening in your directory.
Each filing command, when typed with no parameter, prompts you with:
FILENAME:
to which you would reply WITHOUT mentioning any extension.
1. Filing System - 2 -
Here are the main commands for dealing with files:
.parse
.unparse
.load
.store
.save
Assume you want to start using MENTOR with an already existing PASCAL
program, called EX1.PAS. You should type:
.parse.
FILENAME: ex1
This creates a file that contains the tree representation of your
program. Later on, you will keep all your programs in tree form. To get
the tree form, just type
.load
FILENAME: ex1
The command .save checks that you are indeed saving a full program. If
you wish to keep on a separate file some subexpression, let's say a
procedure - you should use the .store command.
At some point, you will want to make a text file for input to the PASCAL
compiler. The command to use is:
.unparse
FILENAME: ex1
REMARK: All filing procedures may be called with an argument. In that
case, the argument must denote a tree reduced to a single identifier.
You will find this useful whenever you wish to COMPUTE the name of a
file.
2. Addressing Mechanism
-----------------------
MENTOR manipulates programs in tree form. To manipulate programs, you
need to know how to move about in trees, to give a name to a subtree. In
fact, you need to understand MENTOR's addressing mechanism, in the way you
have to understand the addressing mechanism of any usual text editor.
2.1. Markers
------------
The variables of MENTOR are markers into program trees. There is a
conventional marker, called the CURRENT marker, that is used implicitly in
most usual manipulations. If you want to
2.1. Markers - 3 -
name it explicitly, it is called @K. All markers are of the form:
@ <identifier>
(where the identifier is a sequence of at most 8 alphanumeric
characters, starting with an alphabetic character).
2.2. Structural Addresses
-------------------------
A structural address denotes the location of a subtree with respect to
some marker used as a base. The exact syntax is:
<structural address> ::= <marker> |
<structural address><modifier> . (1)
<modifier> ::= <immediate modifier> |
<search mofifier> .
<immediate modifier>::= U <number> | (up)
L <number> | (left)
R <number> | (right)
S <number> | (son)
B <number> | (attribute)
U0 .
<search modifier> ::= F <schema> | (within the subtree)
FF <schema> . (within subtree then
further)
<schema> ::= <structural address> | (schema in store)
D <structural address> | (extracted schema)
<structural address> Z <number> | (sublist schema)
& | (input schema from
terminal)
E <@schema> . (schema obtained by
instantiation)
The modifiers in equation (1) are performed sequentially from left to
right.
2.2.1. Immediate modifiers
--------------------------
For U,L and R the <number> on the right indicates repetition of the
modifier. For S , Sn denotes the n-th son and Sn is equivalent to:
S1R(n-1)
Negative numbers are accepted on the right of S and S-1 designates the
last son, S-2 the one before last, etc.....
2.2. Structural Addresses - 4 -
A star may be used instead of a <number>. The star denotes the largest
possible integer that makes sense for a given modifier. For example:
S* denotes the last son
R* denotes the right-most brother
EXAMPLE: (insert diagram)
@here U denotes A
@here R2 denotes B
@here S* denotes C
@here S2S3 denotes D
ABBREVIATIONS: Whenever the base marker is @K, it may be
omitted. When there is no chance of ambiguity, you can also
omit S. So, in the proper context:
@K S1
is abbreviated
1
The modifiers B and U0 allow you to move from one tree to its attributes
and back. The expression Bn denotes the n-th attribute. At this time, only
2 attributes have been implemented: prefix and postfix attributes, B0 and
B1 respectively. These attributes may either be textual comments, in which
case they are structured as lists of lines, or PASCAL trees. These
attributes may be annotated recursively in the same manner. If you are at
the top of an attribute, the expression U0 will denote the subtree that
this is an attribute of, otherwise it will fail.
2.2.2. Search Modifiers
-----------------------
(A) All search modifiers perform a preorder search for the first
occurrence of the schema given as a parameter. A schema is a tree
- fragment of a program - that may contain some special leaves called
METAVARIABLES. When they are represented, these metavariables appear as:
$<identifier>
A given tree A is an instance of a schema S iff A may be obtained from S
in substituting the metavariables of S by some subtrees.
2.2. Structural Addresses - 5 -
EXAMPLE: (in PASCAL):
Assume the marker @SCH denotes the schema
if $V1 then $V2 else X:=$V3
and that the marker @TXT denotes a tree represented by:
begin
X:=Y
if T=0 then Y:=0
else if B>0 then Z:=0 else X:= A+1
end
The address:
@TXT F @ SCH
denotes the most internal if.
The evaluation of search modifiers has a side effect: it assigns to the
markers whose names are those of the metavariables of the argument schema
the relevant subtree locations. As a consequence, you should only use
LINEAR schemas (i.e. without repetition of metavariables) as arguments of
searches.
In the example above, after evaluating the address @TXT F @SCH, the
markers @V1, @V2 and @V3 denote respectively the occurrences of B>0, Z:=0
and A+1 in the tree denoted by @TXT.
(B) When using the D (delete) modifier, the structural address
denotes the schema obtained after destructive extraction from its
surrounding tree.
(C) The Z operator allows to build a sublist of a list. The
structural address on the left must be that of a list element, and the
number on the right denotes how many elements ih the list should be taken.
EXAMPLE: S-3 Z3 denotes a copy of the last 3 elements of a list.
(D) The symbol & (ampersand) is used whenever a schema must be
input from the console. Whenever the symbol & is evaluated, MENTOR tries
to see from the context what should be parsed. If it is possible, the
user is prompted by the kind of subexpression expected, such as:
[STAT]:
If it is not, the user is prompted with:
[
and should specify first what to parse, typing for example:
stat]<CR>
then it is prompted with a colon indicating that MENTOR is ready to PARSE.
2.2. Structural Addresses - 6 -
(E) Predefined Patterns
To every construct in the abstract syntax corresponds a predefined
schema. If OP is such an construct, @OP denotes the associated schema.
The name of the metavariables in the schema corresponds to the name of the
sorts of the operands. In the case of a list construct, the associated
predefined schema is a one element list. The predefined operators are
very handy to move about in structural trees. For example, the schema @IF
denotes:
if $EXP1 then $STAT1 else $STAT2
and F@IF denotes the first conditional statement encountered in the
current expression. A complete list of predefined schemas can be found in
Appendix C.
(F) Instantiation
The expression E <schema> denotes a new schema obtained after
substitution of the metavariables in the argument schema by the subtrees
denoted by the markers with the same name. The instantiation facility fits
in smoothly with the search capability.
EXAMPLE: Assume the current expression denotes
A+B
and you wish to transform + into -. This may seem difficult
at first since the operator + sits at a node. But since the
predefined schemas @PLUS and @MINUS denote respectively
$EXP1+$EXP2 and $EXP1-$EXP2 , all you have to type is
F@PLUS C E @MINUS
The search modifier collects an environment that is then used
for instantiation.
If you wish to apply rewrite rules to your programs, you will want to use
E.
3. Primitive Commands
---------------------
You can manipulate trees via commands, or procedures. The programming
language of MENTOR is called MENTOL. MENTOL does what you want it to do,
if not always elegantly or safely.
3.1. Handling of Markers - 7 -
3.1. Handling of Markers
------------------------
3.1.1. Assignment
-----------------
<Assignment> ::= <marker>:<structural address> |
<marker>:& .
The second form is to be used when you want to input PASCAL text without
modifying another tree.
ABBREVIATION: When the marker on the left hand side is also the base of
the structural address on the right, you may write instead:
<structural address>
with the same meaning.
EXAMPLE:
@T:@T S2
may be written simply
@T S2
NOTE: This abbreviation combines with the elision of @K so that
@K:@KS2 may be written S2 or even 2.
3.1.2. Stack Manipulation
-------------------------
Each marker denotes in fact, the top of a stack of tree references.
This stack is handled with the commands:
<marker> PD (push-down)
<marker> PU (pushup)
<marker> PT (pushtranspose)
3.2. Handling Trees
-------------------
3.2.1. Printing
---------------
<printing> ::= <structural address> P <number> .
The number on the right must be a positive integer or *. The tree
denoted by the lefthand side is displayed on the teletype up to the level
of detail requested by this number. It is shown entirely if * if used.
The text of the program is abbreviated with # and ... . You can also omit
3.2. Handling Trees - 8 -
the level of detail, in which case the default level is 5. So that:
P
is taken to mean,
@K P 5
3.2.2. Copying
--------------
<copy> ::= <marker> = <schema> .
After the execution of this command, the <marker> denotes a brand new
tree in all cases, so that <marker>U is undefined.
3.2.3. Deleting
---------------
<destruction> ::= D <structural address> .
The designated subtree is extracted from its context. The top of the
special @DUMP marker now denotes this subtree. This allows you to go
backwards if you delete a tree by mistake. The marker @DUMP may contain
the n+1 last deleted trees, provided you have executed @DUMP PD n times
beforehand.
CAUTION: It is not a good idea to saw the branch of the tree on
which you are sitting, when it is a list element. This will make
you jump to the father list node. If you are worried about this,
avoid using the command "D" by itself.
3.2.4. Changing Trees
---------------------
<change> ::= <structural address> C <schema> .
The schema is put at the structural address. The marker @DUMP is
updated with the tree that has been dislodged. MENTOR checks that the
tree you try to insert belongs exactly where you have tried to put it, and
rejects your command otherwise.
3.2.5. Exchanging Trees
-----------------------
<exchange> ::= <structural address> X <structural address> .
The subtrees are exchange, types are checked. Note that this
instruction makes sense only when the addresses denote disjoint subtrees.
3.2. Handling Trees - 9 -
3.2.6. Insertion Within Lists
-----------------------------
<insertion> ::= <structural address> I <schema> |
<structural address> J <schema> |
<structural address> II <schema> |
<structural address> JJ <schema> .
In all cases, the address on the left must denote a list element t. If
you use I, the tree on the right is inserted after t. If you use J, the
tree is inserted before t. Of course, syntactic consistency checks are
performed. With II and JJ, the tree on the right hand side must be a list
of the same kind as the one you insert into. This whole list is merged in
either after t (with II) or before t (with JJ) .
Thus, the primitive commands of MENTOR are:
<primitive command> ::= <assignment> |
<stack-handling> |
<printing> |
<copy> |
<destruction> |
<change> |
<exchange> |
<insertion> .
It is useful to be able to build a sequence of these commands and to
control their flow of execution, just like in any programming language.
4. Control Constructs
---------------------
4.1. Sequencing
---------------
<command list> ::= <command> ; <command list> |
<command> .
Commands in such a list are executed from left to right as soon as the
command list has been received (i.e. after <CR>).
Now a command is defined this way:
<command> ::= <empty command> |
<primitive command> |
<loop> |
<test> |
<case> |
<exit> |
<procedure call> .
The way control proceeds is akin to SNOBOL or TECO. Every command may
succeed or fail. If, in a command sequence, a command fails, the sequence
is interrupted and fails, UNLESS the next command is a test.
4.2. Loop - 10 -
4.2. Loop
---------
<loop> ::= ( <commandlist> ) <number> .
The command list is iterated as specified. If * is specified, the
command list is iterated forever (i.e. probably until it fails or jumps
out). If the number is OMITTED, it is defaulted to 1. In this way, the
parentheses act as usual for you.
4.3. Test
---------
<test> ::= ? <command1> , <command2> .
If the previous command succeeded, the first command is executed
otherwise the second one.
4.4. Case Command
-----------------
<case> ::= <command1> / <command2> .
Command1 is executed. If it suceeds, then command2 is executed, and
then the ENCLOSING list of commands is terminated.
If command1 fails, command2 is not executed, but the case command does
NOT fail.
4.5. Exit
---------
<exit> ::= $ <integer> |
$ - <integer> .
If the integer's value is n, the command jumps out of n levels of loop.
Then, if the minus sign is specified, the command fails. If the integer
is omitted, it defaults to 1.
4.6. Procedure Call
-------------------
All MENTOR procedures (there are, alas, no functions) have a name in the
form:
. <identifer>
A procedure call looks like an ALgol procedure call, except that pointed
brackets are used instead of parentheses.
Procedures may take either structural addresses or commands as parameters.
4.7. Comments - 11 -
4.7. Comments
-------------
Comments are introduced with a % symbol and terminated either with an
end of line or with another %.
Appendix A -Sample session
--------------------------
@mentor
TO CONTINUE HIT THE RETURN KEY *
- MENTOR VERSION 3.5 / JUN-79 ON DEC-10 (HAMBURG)
USER NAME:kahn
KAHN .INI FILE LOADING
? %This question mark is the Mentor prompt symbol
?.load
FILE NAME:newbas
? %Now I have a current expression that is a full program
? %Use P command to see it
?P1
#
? %This was not much information, try more
?P3
program BASIS;
(*$T-*)
...;...;#;#;#;#;
begin
#;#;#;#;#;#;#;#;#;#;#
end.
? %Still more ?
?p4
program BASIS;
(*$T-*)
type #;
var #;#;#;#;#;#;
function PPCM ...:INTEGER;
...;
...;
procedure INITIAL;
...;
...;
procedure FILTER;
...;
...;
procedure XLOOP ...;
...;
...;
begin
INITIAL;
TIM1:=CLOCK;
XLOOP(1,0,INIMAXSUM,INIMAX);
TIM2:=CLOCK;
L:=DIM (*JUMP TRIVIAL SOL*);
while # do ...;
for I:=# do #;
Appendix A - 13 -
WRITELN;
WRITELN('BASIS OF',LSOL1+M*N:5,' SOLUTIONS');
WRITELN;
WRITELN('CPU TIME: ',(TIM2-TIM1)/1000:8,' SEC')
end.
? %Mentor doesn't see the difference between lower and upper case on input
? %Now move to procedure filter
?.fproc
[IDENT]:filter
? %Look at it. P alone means P5
?P
procedure FILTER;
label
1;
var Q,L,L1:INTEGER;
begin
L:=DIM (*JUMP TRIVIAL SOL*);
L1:=1;
Q:=DIM;
while L<=LASTSOL do
begin
#;#;#
end;
Q:=1;
if LASTSOL>=0 then
while # do #;
LASTSOL:=LASTSOL+DIM (*SOL HAS NOT BEEN FILTERED OUT*);
LSOL1:=LSOL1+1;
DIF[LSOL1]:=Q;
for Q:=1 to DIM do #:=#;
1:
end
? %Move to the body of this procedure
?.body
? %Print the second statement
? %but do not go there
?2p
L1:=1
? %exchange second and third statement. Show the result
?2x3;p
begin
L:=DIM (*JUMP TRIVIAL SOL*);
Q:=DIM;
L1:=1;
while L<=LASTSOL do
begin
if # then ...;
L:=#;
L1:=#
end;
Q:=1;
if LASTSOL>=0 then
while SOLS[LASTSOL+Q]=SOL[Q]do Q:=#;
LASTSOL:=LASTSOL+DIM (*SOL HAS NOT BEEN FILTERED OUT*);
Appendix A - 14 -
LSOL1:=LSOL1+1;
DIF[LSOL1]:=Q;
for Q:=1 to DIM do SOLS[LASTSOL+Q]:=SOL[Q];
1:
end
? %insert a statement after the third one
?3i&
[STAT]:if a then b else if c then d;
? %show the fourth statement now
?4p
if A then B
else if C then D
? %go there
?4
?p
if A then B
else if C then D
? %exchange 2nd and third sons. Look what happens!
?2x3;p
if A then
if C then D else
else B
? %note that Mentor looks over your shoulder if you try this
?1x2
E 33 WRONG SYNTAX-TYPES
? %this is because the structure of if statements is known
? %Now change the condition
?1c&
[EXP]:u<=v+w;
?p
if U<=V+W then
if C then D else
else B
? %go to the next statement
?r;p
while L<=LASTSOL do
begin
if DIF[L1]<Q then
begin
#;#;#
end;
L:=L+DIM;
L1:=L1+1
end
? %find the inner if
?f@if;p
if DIF[L1]<Q then
begin
Q:=DIF[L1];
if Q=1 then Q:=2;
while SOLS[L+Q]<=SOL[Q]do
if # then # else #
end
? %go back to the surrounding procedure after noting this place
?@here:@k;.proc;1p
Appendix A - 15 -
procedure FILTER
? %return where you were
?@k:@here
? %put in a prefix comment
?b0c&
[LLINE]:prefix comment *)
?p3
(*PREFIX COMMENT *)
if DIF[L1]<Q then
begin
#;#;#
end
? %Show the next statement
?rp
L:=L+DIM
? %change the logic
?3cdr;u;p
begin
(*PREFIX COMMENT *)
if DIF[L1]<Q then
begin
Q:=#;
if # then #;
while # do #
end else L:=L+DIM;
L1:=L1+1
end
? %go back to the top of the program
?u*
? %show all procedure headings
?.forall<@block,1p>
program BASIS
function PPCM(X,Y:INTEGER):INTEGER
procedure INITIAL
procedure FILTER
procedure XLOOP(I,SUM,MAXSUM:INTEGER;MAXY:TABLE)
procedure YLOOP(I,REST:INTEGER)
? %make a statement schema
?@schema:&
[stat]
:$a:=$b+1;
? %show all occurences of that schema
?.forall<@schema,p>
Q:=Q+1
L1:=L1+1
Q:=Q+1
LSOL1:=LSOL1+1
? %make a new schema
?@schema1:&
[stat]
:increment($a);
? %change program
?.forall<@schema,(p;c e @schema1; p)>
Q:=Q+1
INCREMENT(Q)
Appendix A - 16 -
L1:=L1+1
INCREMENT(L1)
Q:=Q+1
INCREMENT(Q)
LSOL1:=LSOL1+1
INCREMENT(LSOL1)
? %count all assignments in program
?@count:&
[exp]
:0;
?.forall<@ass,.succ<@count>>
?@count p
43
? %try a smaller example to see the normalize procedure
?pd %pushdown current expression
?.load
FILE NAME:dirty
?p*
program DIRTY;
var I,J,K:INTEGER;
procedure USELESS;
begin
begin
end
end;
begin
J:=5;
K:=6;;
begin
;;
end;
USELESS;
for I:=0 to 10 do
begin
WRITELN(I+J+K);
end;
FIN;;;;;;
end.
?.normalize
?p*
program DIRTY;
var I,J,K:INTEGER;
procedure USELESS;
begin
end (*USELESS*);
(*BODY OF DIRTY*)
begin
J:=5;
K:=6;
Appendix A - 17 -
USELESS;
for I:=0 to 10 do WRITELN(I+J+K);
FIN
end.(*DIRTY*)
? %I like it better like that
? %Now load a library called doc
?.xin
FILE NAME:doc
E 30 MACRO EXISTS
E 30 MACRO EXISTS
? %messages indicating procedure redefinition because of name conflicts
?pu;u* %to get back to my original program
?.doc
?p*
program BASIS;
(*$T-*)
type TABLE =;
var INIMAX,COEF,SOL,D,E,SOLS,DIF,TIM1,TIM2,LASTSOL,LSOL1,MAXA,MAXB,
INIMAXSUM,I,J,CDIM,L,M,N,DIM:;
function PPCM(X,Y:);
var P:;
procedure INITIAL;
var I,J,P:;
procedure FILTER;
label
1;
var Q,L,L1:;
procedure XLOOP(I,SUM,MAXSUM:;MAXY:);
label
1;
var K:;
procedure YLOOP(I,REST:);
label
2;
var K:.
? %what are the Mentol procedures and variables currently defined ?
?.help
TYPE HELP IF LOST
-procs
SPFRECD FIXPAS DDEF AND UP
CONCAT PUTREF1 APROC SPFCONST TRACE
PUTVAR COMBODS ISFIRSTLEV SEEK FPROC
FORALL APL CTX RUTGERS SPFVALUE
PROC PUTDEF BODY PURGIV SPFVAR
Appendix A - 18 -
ENTERD DOC SPFENT APLSPL LABEL
SPFTYP1 NEXTIN PUTREF OR NEXT
NORMALIZE FOREACH CLEAN LEFTMS MKBODYOF
FIXPOST DVAR VAR SPFBODY SPFTYP
COMPROCS COND CASE SAUVE FILTER
LAB LASTCASE EXIT ENTER FIXPRE
TYP VAL CON NEWUPDATE PUTDEF1
-vars
B NODEBUG LOCAL1 PROG SET
FIRST LSTAT HERE STAT2 PASCAL2
CONSTANTES LLINE DEF WHILE PASCAL1
LINE A STAT1 REPEAT UPDATELOC
VALUE EQLT1 CONST FILE PASCAL
TYPE VARBL1 PROC EXP1 NULL
DUMP FORWARD BODY1 FOR UPDATELOC1
TYP1 L2 RANGE FUNC CST2
IF UPDATELOC2 DECL LC1 LZONE1
ARRAY CCC V ASS DECL1
CST1 COUNT SCHEMA1 K TITLE1
LC2 LIDENT MODULSEM VAR LTYP1
PACKED SCHEMA BLOCK METASYM REF
LCHAR LINE1 IDENT BODYOF USERNAME
-
? %the list above contains all markers ever defined, even locally.
? %This session could go on and on. It is your turn to try to use
? % MENTOR
?.end
EXIT LEV.1-PASCAL
EXIT
Appendix B -System constants
----------------------------
Predefined procedures
---------------------
DEF REDEF PRMAC DELMAC LDEF
LREDEF LBODY ASS REASS DUMP
EQTYPE EQVAL IS EQUAL LT
REC HELP ERR SET RESET
TEST STYPE USER DAY SUCC
MKINT END MKPTR IN EVAL
PP CONCAT COERCE FIND RESUME
ONINTER WHEREINT GENSYM INPUT XIN
XOUT SAVE RESTORE PARSE STORE
LOAD DELETE DELTXT DEVOUT DEVIN
UNPARSE
Toggles that you can set and reset
----------------------------------
DEBUG WPROTECT COMMENT ECOMMENT ECHO
PRESTEP POSTSTEP NOSTEP INTERRUP KWUC
WIDELINE PERCENT BRACE PARSTAR INFSUP
SHARP AROB UPARROW SQUARE PARDOT
ANDOR AMPERBAR TILDEQ TILDNOT NOTNOT
HEXAX HEXAQQ XPASCAL XEXTERN XTERNAL
HEXASH METAKEY DECHEAD MODULSEM INITPROC
INIVALUE UNDSCORE F37 F38 F39
F57 F58 SKIPEOF STEPOK VERBOSE
ALFA8 STEPETAT
Appendix C -The Abstract syntax of Pascal
-----------------------------------------
PHYLA TABLE
every :: IDENT META INTCST ALFACST CHARCST NIL HEXCST
REALCST METASYM PASCAL FORWARD LINE SETOF NOT
UPLUS UMINUS UNREF HEXA DEF FUNCPAR VARPAR
REF PACKED FILE SET PROCPAR GOTO EQLC
EQLT EQLV INTERV EQL LSS GTR NEQ
LEQ GEQ IN INTDIV MOD DIV MULT
PLUS MINUS OR AND INDEX DOT FORMAT
RANGE CASERC ARRAY DECTAG COLRC DECL UPSTEP
DWNSTEP REPEAT ASS CALL CASE COLON WHILE
WITH LABSTAT TIMES PROG PROC LELEM LABEL
LEXP LIDENT LCST LDEFID VAR LTYP LFIELD
LCOLRC LSTAT LCOLON LVARBL LPARAM LVAL CONST
TYPE VALUE LZONE LLINE LCHAR FOR IF
FUNC BLOCK
cst :: IDENT META INTCST ALFACST CHARCST NIL HEXCST
REALCST
varbl :: IDENT META UNREF INDEX DOT
casetg :: IDENT META DECTAG
exp :: IDENT META INTCST ALFACST CHARCST NIL HEXCST
REALCST SETOF NOT UPLUS UMINUS UNREF HEXA
EQL LSS GTR NEQ LEQ GEQ IN
INTDIV MOD DIV MULT PLUS MINUS OR
AND INDEX DOT FORMAT CALL
elem :: IDENT META INTCST ALFACST CHARCST NIL HEXCST
REALCST SETOF NOT UPLUS UMINUS UNREF INTERV
EQL LSS GTR NEQ LEQ GEQ IN
INTDIV MOD DIV MULT PLUS MINUS OR
AND INDEX DOT CALL
stat :: META GOTO REPEAT ASS CALL CASE WHILE
WITH LABSTAT LSTAT FOR IF
step :: META UPSTEP DWNSTEP
param :: META PROCPAR DECL
local :: META FUNCPAR VARPAR LDEFID
spltyp :: IDENT META RANGE LIDENT
typ :: IDENT META REF PACKED FILE SET RANGE
ARRAY LIDENT VAR LFIELD
defid :: IDENT META DEF
body :: META METASYM PASCAL FORWARD LSTAT
field :: META CASERC DECL
Appendix C - 21 -
val :: IDENT META INTCST ALFACST CHARCST NIL HEXCST
REALCST TIMES
valu :: IDENT META INTCST ALFACST CHARCST NIL HEXCST
REALCST LVAL
zone :: META LABEL VAR CONST TYPE VALUE BLOCK
title :: META PROG PROC FUNC
STRUCTURE OF OPERATORS
TERMINAL OPERATORS
IDENT META INTCST ALFACST CHARCST NIL HEXCST REALCST
METASYM PASCAL FORWARD LINE
OTHER OPERATORS
SETOF --> lelem
NOT --> exp
UPLUS --> exp
UMINUS --> exp
UNREF --> varbl
HEXA --> exp
DEF --> ident
FUNCPAR --> ldefid
VARPAR --> ldefid
REF --> ident
PACKED --> typ
FILE --> typ
SET --> spltyp
PROCPAR --> lident
GOTO --> intcst
EQLC --> ident cst
EQLT --> ident typ
EQLV --> ident valu
INTERV --> exp exp
EQL --> exp exp
LSS --> exp exp
GTR --> exp exp
NEQ --> exp exp
LEQ --> exp exp
GEQ --> exp exp
IN --> exp exp
INTDIV --> exp exp
MOD --> exp exp
DIV --> exp exp
MULT --> exp exp
PLUS --> exp exp
MINUS --> exp exp
OR --> exp exp
AND --> exp exp
INDEX --> varbl lexp
DOT --> varbl ident
FORMAT --> exp exp
RANGE --> cst cst
Appendix C - 22 -
CASERC --> casetg lcolrc
ARRAY --> ltyp typ
DECTAG --> ident ident
COLRC --> lcst lfield
DECL --> local typ
UPSTEP --> exp exp
DWNSTEP --> exp exp
REPEAT --> lstat exp
ASS --> varbl exp
CALL --> ident lexp
CASE --> exp lcolon
COLON --> lcst stat
WHILE --> exp stat
WITH --> lvarbl stat
LABSTAT --> intcst stat
TIMES --> intcst cst
PROG --> defid lident
PROC --> defid lparam
LELEM --> elem ...
LABEL --> intcst ...
LEXP --> exp ...
LIDENT --> ident ...
LCST --> cst ...
LDEFID --> defid ...
VAR --> decl ...
LTYP --> spltyp ...
LFIELD --> field ...
LCOLRC --> colrc ...
LSTAT --> stat ...
LCOLON --> colon ...
LVARBL --> varbl ...
LPARAM --> param ...
LVAL --> val ...
CONST --> eqlc ...
TYPE --> eqlt ...
VALUE --> eqlv ...
LZONE --> zone ...
LLINE --> line ...
LCHAR --> charcst ...
FOR --> ident step stat
IF --> exp stat stat
FUNC --> defid lparam ident
BLOCK --> title lzone body
Appendix D - Entry points in the PASCAL parser
----------------------------------------------
In Mentor, you do not need in general to know the name of the
parser entry points because they will be supplied automatically by
the system. However, when you wish to enter a PASCAL program
fragment with no context at all, for example when defining a
schema, you will be asked for a parser entry point. The most
useful entry points are listed here.
EXP an expression
STAT a statement
IDENT an identifier
LINE a line of comment terminated by carriage return
DECL a declaration of one or more variables of the same type
PROGRAM a complete program
EQLT a type declaration
EQLC a constant declaration
ZONE a LABEL, CONST, TYPE, VAR zone or a PROCEDURE or a FUNCTION
COLON a case in a CASE statement
FIELD a field in a record declaration
VARBL an expression that may appear on the left hand side of an assignment
TITLE a program,procedure or function header
STEP the step part of a FOR statement
LEXP a list of expressions surrounded by parentheses, separated by commas
LSTAT a list of statements surrounded by begin end separated by semicolons
LIDENT a list of identifiers separated by commas
LLINE a list of lines separated by carriage returns and terminated by *)
LZONE a list of zones separated and terminated by semicolon
LCOLON a list of cases separated by semicolons terminated by end
LFIELD a list of fields surroundeb by record end and separated by semicolons
LVARBL a list of variables, separated by commas (occur in with statement)